﻿/*@charset "UTF-8";*/
/*----------------------------------------------
for official portal index
$Id: iDefault.js, v1.1 2011/8/8 02:29:08 jf $
----------------------------------------------*/
var zTree;
var zNodes = null;
var setting = {
    isSimpleData: true,
    treeNodeKey: "id",
    treeNodeParentKey: "pId",
    showLine: true,
    callback: {
        beforeExpand: zTreebeforeExpand,
        click: treeNodeclick
    }
};

$(document).ready(function () {
    ResizeImg(); infoDeCode();
    setProArea(); 
});

function zTreebeforeExpand(treeId, treeNode) {
    if (zTree.getNodeByParam("pId", treeNode.id) == null) { return false; }
}
function refushtreenode() {
    var nodes = zTree.getNodesByParam("level", "0");
    for (i = 0; i < nodes.length; i++) {
        if (zTree.getNodesByParam("pId", nodes[i].id).length == 0) {
            $("#" + nodes[i].tId + " :button").eq(0).removeClass("switch_roots_close switch_center_close switch_bottom_close");
        }
    }
}
function treeNodeclick(event, treeId, treeNode) {
    if (zTree.getNodeByParam("pId", treeNode.id) == null) {
        $("#HidSetgl").val(treeNode.id); $("#BtnSetgl").click();

    }
    else { zTree.expandNode(treeNode, true, false); }
};
function setProArea() {
    $(".disType").change(function () { if ($(this).val() == "PRICE") { $(this).nextAll().eq(0).hide(); $(this).nextAll().eq(1).show(); } else { $(this).nextAll().eq(1).hide(); $(this).nextAll().eq(0).show(); } });

    $(".disCommit").click(function () {
        var dismsg = "优惠信息："; var ddobj = $(this).prev(); var diobj = $(this).parent().prev();
        ddobj.children().each(function () {
            if ($(this).css("display") != "none") {
                if ($(this).val() == "DISCOUNT") { dismsg += "折扣"; }
                else if ($(this).val() == "PRICE") { dismsg += "优惠价格"; }
                else if (dismsg == "折扣") { dismsg += "：" + $(this).val() + "折"; }
                else if (dismsg == "优惠价格") { dismsg += "：" + $(this).val() + "元"; }
                else { dismsg += "，" + $(this).val() + "小时"; }
            }
        });
        diobj.children().eq(0).text(dismsg); diobj.children().eq(1).text("取消优惠"); ddobj.parent().hide(); diobj.slideDown();
    }); 
}
function SetPromotion(obj) {
    if ($(obj).text() == "设置优惠") { $(obj).next().val("true"); $(obj).parent().hide(); $(obj).parent().next().slideDown("fast"); }
    else { $(obj).next().val("false"); $(obj).text("设置优惠"); $(obj).prev().text("此商品还未设置打折信息！"); }
}
function CustomSubmit(msg) {
    var form = document.getElementById("frm_iDefault");
    document.getElementById('hID').value = confirm(msg);
    form.submit();
}
function popupTips(msg) {
    parent.alert(msg);
    parent.location.reload();
};
